import Koa from "koa";
import { appPort } from "./utils/portSetting.js";
import bodyParser from "koa-bodyparser";
import router from "./router/index.js";
import { sync } from "./db/index.js";
import koaCors from "koa-cors";

const app = new Koa(); //创建koa实例

app.use(bodyParser()); //解析json请求体

app.use(koaCors()); //解决跨域问题



sync();  //连接数据库

app.use(router); //使用路由中间件

//监听端口
app.listen(appPort, () => {
  console.log(`服务运行地址于:http://localhost:${appPort}`);
});
